const fs = require('fs-extra')
const path = require('path')
const ejs = require('ejs') // 模板引擎

let config = {
  src: path.join(__dirname, 'template')
}

module.exports = {
  copy (ans) {
    config.ans = ans
    config.dest = path.join(process.cwd(), ans.name)
    return fs.copy(config.src, config.dest)
  },
  fill () {
    const file = 'index.html'
    ejs.renderFile(path.join(config.src, file), config.ans, (err, data) => {
      if (err) throw err
      fs.writeFileSync(path.join(config.dest, file), data)
    })
  }
}
